/* bitfield.h is part of VIP program
 * Written by J. Salvador Arias, 2010
 *      CONICET, INSUE, Instituto Miguel Lillo,
 *      Miguel Lillo 205, S.M. de Tucuman (4000)
 *      Tucuman, Argentina
 *      e-mail: jsalarias@csnat.unt.edu.ar
 *
 * VIP is a free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation and
 * Creative Commons.
 *
 * This file and the VIP program is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * To view a copy of this license, visit
 * http://creativecommons.org/licenses/GPL/2.0/
 * or send a letter to
 * Creative Commons, 171 Second Street, Suite 300,
 * San Francisco, California, 94105, USA.
 */


#ifndef BIT_FIELD_HEADER_INCLUDED
#define BIT_FIELD_HEADER_INCLUDED

/* ------ Bit field header ------ */
/* A set of bitfield operations */

#include "ghead.h"

typedef guint16 BITFIELD;
#define BITS_ON_FIELD 16

/* ------ Globals ------ */
gsize maxFieldSize;
#define GETBITFIELDSIZE maxFieldSize

void StartBitFields (SCOUNTER bits);
void EndBitFields ();

BITFIELD* CreateBitField ();
void ResetBitField (BITFIELD* a);

void PutBitOn (BITFIELD* a, SCOUNTER bit);
SFLAG IsBitOn (BITFIELD* a, SCOUNTER bit);
void CopyBitField (BITFIELD* dest, BITFIELD* src);

SFLAG BitFieldAnd (BITFIELD* a1, BITFIELD* a2);
SFLAG BitFieldEqual (BITFIELD* a1, BITFIELD* a2);

void BitFieldORsum (BITFIELD* dest, BITFIELD* src);
void BitFieldANDsum (BITFIELD* dest, BITFIELD* src);
void BitFieldRemove (BITFIELD* dest, BITFIELD* toRemov);

void BitFieldAddNotRemoved (BITFIELD* dest, BITFIELD* src, BITFIELD* toRemov);

SCOUNTER CountBits (BITFIELD* a);
SCOUNTER BitFieldCommon (BITFIELD* a, BITFIELD* b);

#endif
